﻿using System;
using System.Collections.Generic;
using Missbot.Service;
using MongoDB.Bson.Serialization.Attributes;

namespace Missbot.AIModule.Record
{
    public class CharactorSetting : DbBaseEntity
    {
        public string GroupID { get; init; }
        
        public string Creator { get; init; }
        
        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime CreateTime { get; set; }
        
        public string Charactor { get; init; }
        
        public string SettingName { get; init; }
        
        public string Content { get; set; }
    }

    public static class CharactorSettingDA
    {
        public static IEnumerable<CharactorSetting> GetByGroupCharactor(string GroupID, string Charactor)
        {
            return MongoService<CharactorSetting>.Get(cs => cs.GroupID == GroupID && cs.Charactor == Charactor);
        }

        public static List<CharactorSetting> GetByGroupCreator(string GroupID, string creator)
        {
            return MongoService<CharactorSetting>.Get(cs => cs.GroupID == GroupID && cs.Creator == creator);
        }

        public static void Insert(this CharactorSetting entity)
        {
            MongoService<CharactorSetting>.Insert(entity);
        }

        public static void Update(this CharactorSetting entity)
        {
            MongoService<CharactorSetting>.Update(entity);
        }

        public static void Delete(this CharactorSetting entity)
        {
            MongoService<CharactorSetting>.Delete(entity);
        }

        public static IEnumerable<CharactorSetting> GetGroupCharactorSetting(string GroupID, string Charactor, string settingName)
        {
            return MongoService<CharactorSetting>.Get(cs => cs.GroupID == GroupID && cs.Charactor == Charactor && cs.SettingName == settingName);
        }
        
        public static CharactorSetting GetOnly(string GroupID, string Charactor, string settingName)
        {
            return MongoService<CharactorSetting>.GetOnly(cs => cs.GroupID == GroupID && cs.Charactor == Charactor && cs.SettingName == settingName);
        }
        
        public static List<CharactorSetting> GetGroupCharactorNotSetting(string GroupID, string Charactor, string settingName)
        {
            return MongoService<CharactorSetting>.Get(cs => cs.GroupID == GroupID && cs.Charactor == Charactor && cs.SettingName != settingName);
        }
    }
}